﻿<UserControl x:Class="ScrumFactory.Windows.SprintIndicator"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
             xmlns:props="clr-namespace:ScrumFactory.Windows.Properties"
            xmlns:SF_Helpers="clr-namespace:ScrumFactory.Windows.Helpers;assembly=ScrumFactory.Windows.Helpers"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             
             Tag="{Binding DataContext.Project.CurrentValidSprint, RelativeSource={RelativeSource AncestorType={x:Type SF_Helpers:DockWindowContainer}}}">
    
  
    <UserControl.ToolTip>
        <ToolTip DataContext="{Binding Path=PlacementTarget.Tag, RelativeSource={RelativeSource Self}}">
            <StackPanel>
                <TextBlock Margin="0,0,0,4">
                <TextBlock Text="{Binding SprintNumber, StringFormat='{}Sprint {0}'}" /> 
                <TextBlock Text="{Binding DaysLeft, StringFormat={x:Static props:Resources._N_days_left}}" /> 
            </TextBlock>

                <ItemsControl ItemsSource="{Binding Days}">
                    <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </ItemsControl.ItemsPanel>
                    <ItemsControl.ItemTemplate>
                        <DataTemplate>
                            <Border Width="20"  Margin="0,0,2,0">
                                <TextBlock Text="{Binding Day}" Foreground="Black" TextAlignment="Center" VerticalAlignment="Center"/>
                                <Border.Style>

                                    <Style TargetType="Border">
                                        <Setter Property="Background" Value="White"/>
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding ., Converter={StaticResource CompareDateConverter}}" Value="-1">
                                                <Setter Property="Background" Value="LightGray"/>
                                            </DataTrigger>
                                            <DataTrigger Binding="{Binding ., Converter={StaticResource CompareDateConverter}}" Value="0">
                                                <Setter Property="Background" Value="{StaticResource WorkingBacklogItemBackground}"/>
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Border.Style>
                            </Border>
                        </DataTemplate>
                    </ItemsControl.ItemTemplate>
                </ItemsControl>
            </StackPanel>
        </ToolTip>
      </UserControl.ToolTip>
    <UserControl.Style>
        <Style TargetType="UserControl">
            <Style.Triggers>
                <DataTrigger Binding="{Binding DataContext.Project.ProjectType, RelativeSource={RelativeSource AncestorType={x:Type SF_Helpers:DockWindowContainer}}}" Value="30">
                    <Setter Property="Visibility" Value="Collapsed"/>
                </DataTrigger>
            </Style.Triggers>
        </Style>
    </UserControl.Style>

    <StackPanel Orientation="Horizontal">

        <TextBlock Text="Sprints" VerticalAlignment="Center"  Foreground="{StaticResource TitleTextBrush}" FontSize="{StaticResource SmallFontSize}" Margin="0,0,4,0"/>
        <ItemsControl ItemsSource="{Binding DataContext.ProjectSprints, RelativeSource={RelativeSource AncestorType={x:Type SF_Helpers:DockWindowContainer}}}" MaxWidth="300">
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Rows="1"  />
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
            <ItemsControl.ItemTemplate>
                <DataTemplate>
                    <Border  Margin="0,0,2,0" BorderThickness="2" MaxWidth="20" MinWidth="15" Height="14" >
                        
                        <Border.Style>
                            <Style TargetType="Border">
                                <Setter Property="Background" Value="Gray"/>
                                <Setter Property="BorderBrush" Value="Gray"/>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding IsOver}" Value="True">
                                        <Setter Property="Background" Value="{StaticResource DoneBacklogItemBackground}"/>
                                        <Setter Property="BorderBrush" Value="{StaticResource DoneBacklogItemBackground}"/>
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding IsCurrent}" Value="True">
                                        <Setter Property="Background" Value="{StaticResource WorkingBacklogItemBackground}"/>
                                        <Setter Property="BorderBrush" Value="Yellow"/>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Border.Style>
                    </Border>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
        </ItemsControl>
    </StackPanel>
  
    
</UserControl>
